package main

import (
	"fmt"
	"log"
	"time"
)

func main() {
	ch := make(chan string)
	ch2 := make(chan string)
	go Produce01(ch)
	go Produce02(ch2)
	go Consume01(ch, ch2)
	time.Sleep(30 * time.Second)
}

func Produce01(ch chan string)  {
	for i := 0; i < 20; i++ {
		ch <- fmt.Sprintf("Produce01_%d", i)
		time.Sleep(1 * time.Second)
	}
}
func Produce02(ch chan string)  {
	for i := 0; i < 20; i++ {
		ch <- fmt.Sprintf("Produce02_%d", i)
		time.Sleep(500 * time.Millisecond)
	}
}

func Consume01(ch, ch2 chan string) {
	for true {
		select {
		case data := <- ch:
			log.Println(data)
		case data2 := <- ch2:
			log.Println(data2)
		}
	}
}